package com.guan.ordering_sys.exception;

import com.guan.ordering_sys.common.StateCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * TODO
 *
 * @author olay
 * @version 1.0
 * @date 6/4/2021 9:03 AM
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class BaseException extends RuntimeException {
    private Integer errorCode;
    private String message;
    private String data;
    private StateCode stateCode;

    public BaseException(String message) {
        this.message = message;
    }

    public BaseException(StateCode stateCode) {
        this.stateCode = stateCode;
    }

    public BaseException(Integer errorCode, String message) {
        super(message);
        this.errorCode = errorCode;
        this.message = message;
    }

    public BaseException(StateCode errorCode, String data) {
        super(data);
        this.errorCode = errorCode.getCode();
        this.message = errorCode.getMessage();
        this.data = data;
    }

}
